package com.passengerflowmanagementsystem.statistics.service.impl;

import java.util.List;
import com.passengerflowmanagementsystem.common.utils.DateUtils;
import com.passengerflowmanagementsystem.statistics.domain.EmExhibitionShop;
import com.passengerflowmanagementsystem.statistics.mapper.EmExhibitionShopMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.passengerflowmanagementsystem.statistics.mapper.EmExhibitionHallMapper;
import com.passengerflowmanagementsystem.statistics.domain.EmExhibitionHall;
import com.passengerflowmanagementsystem.statistics.service.IEmExhibitionHallService;

/**
 * 展厅Service业务层处理
 * 
 * @author sheng
 * @date 2024-10-28
 */
@Service
public class EmExhibitionHallServiceImpl implements IEmExhibitionHallService 
{
    @Autowired
    private EmExhibitionHallMapper emExhibitionHallMapper;

    @Autowired
    private EmExhibitionShopMapper emExhibitionShopMapper;

    /**
     * 查询
     *
     * @param hallId
     * @return
     */
    @Override
    public EmExhibitionHall selectEmExhibitionHallByHallId(Long hallId)
    {
        return emExhibitionHallMapper.selectEmExhibitionHallByHallId(hallId);
    }

    /**
     * 查询
     * 
     * @param emExhibitionHall
     * @return
     */
    @Override
    public List<EmExhibitionHall> selectEmExhibitionHallList(EmExhibitionHall emExhibitionHall)
    {
        List<EmExhibitionHall> hallList = emExhibitionHallMapper.selectEmExhibitionHallList(emExhibitionHall);
        if (hallList.stream().count() > 0){
            for (EmExhibitionHall hall :hallList){
                if (hall.getShopId() != null){
                    EmExhibitionShop shop = emExhibitionShopMapper.selectEmExhibitionShopByShopId(hall.getShopId());
                    if (shop != null){
                        hall.setShopName(shop.getShopName());
                    }
                }
            }
        }
        return hallList;
    }

    /**
     * 新增
     * 
     * @param emExhibitionHall
     * @return
     */
    @Override
    public int insertEmExhibitionHall(EmExhibitionHall emExhibitionHall)
    {
        emExhibitionHall.setCreateTime(DateUtils.getNowDate());
        return emExhibitionHallMapper.insertEmExhibitionHall(emExhibitionHall);
    }

    /**
     * 修改
     * 
     * @param emExhibitionHall
     * @return
     */
    @Override
    public int updateEmExhibitionHall(EmExhibitionHall emExhibitionHall)
    {
        emExhibitionHall.setUpdateTime(DateUtils.getNowDate());
        return emExhibitionHallMapper.updateEmExhibitionHall(emExhibitionHall);
    }

    /**
     * 批量删除
     *
     * @param hallIds
     * @return
     */
    @Override
    public int deleteEmExhibitionHallByHallIds(Long[] hallIds)
    {
        return emExhibitionHallMapper.deleteEmExhibitionHallByHallIds(hallIds);
    }

    /**
     * 删除
     * 
     * @param hallId
     * @return
     */
    @Override
    public int deleteEmExhibitionHallByHallId(Long hallId)
    {
        return emExhibitionHallMapper.deleteEmExhibitionHallByHallId(hallId);
    }
}
